﻿@using Microsoft.AspNet.Identity
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    @RenderSection("meta", required: false)
    <link rel="icon" type="image/png" href="~/Content/img/fav.ico">

    <title>WriterStars</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    <link href="~/Content/Site.css" rel="stylesheet" />
    @*<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">*@
    <link href='https://fonts.googleapis.com/css?family=Roboto:400,300,700&subset=latin,cyrillic-ext' rel='stylesheet' type='text/css'>
    <style>
    body{
        font-family: 'Roboto', sans-serif;
    }
    </style>

</head>
<body>

    <nav class="navbar navbar-inverse nav-main border-brand">
        <div class="container-fluid">
            <div class="navbar-header page-scroll">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand page-scroll" href="/">S-KEEPER</a>
            </div>

            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                @Html.Partial("_LoginPartial")
                <ul class="nav navbar-nav navbar-right">
                    <li class="hidden active">
                        <a href="#page-top"></a>
                    </li>

                    @if (this.Request.IsAuthenticated)
                    {
                        <li>@Html.ActionLink("Library", "index", "library")</li>
                        <li>@Html.ActionLink("About", "about", "home")</li>
                    }

                    @if (this.User.IsInRole("Administrator"))
                    {
                        <li>@Html.ActionLink("Admin", "Index", "Admin")</li>
                    }

                </ul>
            </div>
        </div>
    </nav>
    <div class="body-wrapper">
        <div class="landing-shader">
            <div class="body-content container">
                @RenderBody()
            </div>
        </div>
    </div>

    

    <footer class="site-footer">
        <br />
        <div class="container">
            <div class="row">
                <div class="col-xs-12 footer-info-wrapper">
                    <div class="text-center">
                        General Contact:
                    </div>
                    <div class="text-center">
                        <span class="fa fa-fw fa-envelope-o"></span> stefan@@s-keeper.mk
                    </div>
                </div>
                <div class="col-xs-12 footer-info-wrapper">
                    <div class="text-center">
                        Stay in touch:
                    </div>
                    <div class="text-center">
                        <span class="fa fa-fw fa-facebook-official"></span> Facebook
                    </div>
                    <div class="text-center">
                        <span class="fa fa-fw fa-twitter"></span> Twitter
                    </div>
                </div>
            </div>
            <h3 class="text-center" style="font-size:20px; color:#ffce00">WWW.S-KEEPER.MK</h3>
            <p class="text-center" style="padding-bottom:10px; padding-top:20px; margin-bottom:0;">
                &copy; @DateTime.Now.Year Copyright WriterStars All right reserved
            </p>
        </div>
    </footer>


    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")

    <div id="fb-root"></div>
    <script>
        (function (d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3&appId=@(Request.IsLocal ? "1422636174697223" : "1422591451368362")";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
    </script>

    <script>
        function statusChangeCallback(response) {
            
            //console.log('statusChangeCallback');
            //console.log(response);
            if (response.status === 'connected') {
                testAPI();
            }
            //else if (response.status === 'not_authorized') {
            //    document.getElementById('status').innerHTML = 'Please log ' +
            //      'into this app.';
            //} else {
            //    document.getElementById('status').innerHTML = 'Please log ' +
            //      'into Facebook.';
            //}
        }

        function checkLoginState() {
            FB.getLoginStatus(function (response) {
                statusChangeCallback(response);
            });
        }

        window.fbAsyncInit = function () {
            window.fbAsyncInit = function () {
                FB.init({
                    appId: @(!this.Request.IsLocal ? "1422591451368362" : "1422636174697223"),
                    xfbml: true,
                    version: 'v2.2'
                });
            };

            FB.getLoginStatus(function (response) {
                statusChangeCallback(response);
            });
        };

        (function (d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) { return; }
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/en_US/sdk.js";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));

        function testAPI() {
            console.log('Welcome!  Fetching your information.... ');
            FB.api('/me', function (response) {
                console.log('Successful login for: ' + response.name);
                document.getElementById('status').innerHTML =
                  'Thanks for logging in, ' + response.name + '!';
            });
        }
    </script>

    <script src="~/Scripts/bootstrap3-wysihtml5.all.min.js"></script>
    <script>
        function namespace(namespaceString) {
            var parts = namespaceString.split('.'),
                parent = window,
                currentPart = '';

            for (var i = 0, length = parts.length; i < length; i++) {
                currentPart = parts[i];
                parent[currentPart] = parent[currentPart] || {};
                parent = parent[currentPart];
            }
            return parent;
        }

        var myApp = namespace('myApp');
        myApp.currentUserId = '@this.User.Identity.GetUserId()';

        myApp.upvote = function (bookId) {
            $.post('/Book/Like/', 'bookId=' + bookId, function (data, status) {
                var $likesSpan = $('#likes-count[book="' + bookId + '"]');
                var currentCount = parseInt($likesSpan.html());
                $likesSpan.html(currentCount + 1);
                $('.like-btn').hide();
                $('.dislike-btn').show('fade');
            });
        }

        myApp.downvote = function (bookId) {

            $.post('/Book/Dislike/', 'bookId=' + bookId, function (data, status) {
                var $likesSpan = $('#likes-count[book="' + bookId + '"]');
                var currentCount = parseInt($likesSpan.html());
                $likesSpan.html(currentCount - 1);
                $('.dislike-btn').hide();
                $('.like-btn').show('fade');
            });
        }

        function extractHtml(htmlString) {
            var regex = /(<([^>]+)>)/ig,
                result = htmlString.replace(regex, "");

            return result;
        }

        function formatResult(htmlExtracted) {
            var trimmed = htmlExtracted.trim(),
                splitted = trimmed.split(' '),
                filtered = splitted.filter(function (x) {
                    return x != '';
                }),
                joined = filtered.join(' '),
                formatted = joined.replace('&emsp;', ' ').replace('&nbps;', '');
            return formatted;
        }
    </script>
    @RenderSection("scripts", required: false)
</body>
</html>
